import("/lay/lib/jquery-3.4.1/jquery-3.4.1.min.js")

//ajax判断班级是否存在
function exitClass() {
    let className = $("#className").val();
    $.get("class/exitClass", {className: className}, function (result) {
        if (result.success == false) {
            $("#redmsg1").remove();
            $("#message1").append("<span id='redmsg1' style='color: red'>" + '*班级不存在*' + "</span>");
            $("#className").val("");
        } else {
            $("#redmsg1").remove();
        }
    })

}

//验证身份中
function checkIdCard() {

    let idCard = $("#idcard").val();
    let str =/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/;
    if (!str.test(idCard)) {
        $("#idCardmsg").remove();
        $("#card").append("<span id='idCardmsg' style='color: red'>" + '*身份证号有误*' + "</span>");
        $("#idcard").val("");
    }else {
        $("#idCardmsg").remove();
    }
}
//验证手机号
function checkPhone() {
    let phone = $("#phone").val();
    let str = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/;
    if (!str.test(phone)) {
        $("#phonemsg").remove();
        $("#Iphone").append("<span id='phonemsg' style='color: red'>" + '*手机号有误*' + "</span>");
        $("#phone").val("");
    }else {
        $("#phonemsg").remove();
    }
}

//验证邮箱
function checkEmail() {
    let email = $("#email").val();
    let str = /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/;
    if (!str.test(email)) {
        $("#emailmsg").remove();
        $("#Iemail").append("<span id='emailmsg' style='color: red'>" + '*邮箱有误*' + "</span>");
        $("#email").val("");
    }else {
        $("#emailmsg").remove();
    }
}

//验证qq号

function checkQQ() {
    let email = $("#qq").val();
    let str = /^[1-9][0-9]{5,10}/;
    if (!str.test(email)) {
        $("#qqmsg").remove();
        $("#Iqq").append("<span id='qqmsg' style='color: red'>" + '*qq账号有误*' + "</span>");
        $("#qq").val("");
    }else {
        $("#qqmsg").remove();
    }
}